package tcp;

import java.io.IOException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA
 * Description
 * User：chenshu
 * Date：2023-11-24
 * Time：11:28
 */
public class DictServer extends  EchoServer{
    HashMap<String, String> dict = new HashMap<>();
    public DictServer(int port) throws IOException {
        super(port);
        dict.put("cat", "猫");
        dict.put("dog", "狗");
        dict.put("hello", "你好");
        dict.put("world", "世界");
    }

    @Override
    public String process(String request) {
        String response = dict.getOrDefault(request, "没有这个单词");
        return response;
    }

    public static void main(String[] args) throws IOException {
        DictServer dictServer = new DictServer(8000);
        dictServer.start();
    }
}
